package gameElements.item;

import java.awt.Graphics2D;
import java.awt.Image;

import constInterface.BulletKind;
import gameElements.role.Lead;
import reader.DataReader;

public class Box extends Item implements BulletKind
{
	private static final String name = "blue_";
	
	
	public Box(float realX, float realY) 
	{
		super(realX, realY);
	}
	
	public void hit(Lead lead)
	{
		super.hit(lead);
		lead.addBullet((int) (Math.random()*(BULLET_NUM-1))+1, 10);
		
	}
	
	
	private int frame = 0;
	private int itemImage = 0;
	public void drawSelf(Graphics2D g) {
		now = DataReader.getDataReader().getImage(name+itemImage);
		frame ++;
		if(now == null)
		{
			itemImage = 0;
			drawSelf(g);
			return;
		}
		setWidth( now.getWidth(null));
		setHeight(now.getHeight(null));
		if(frame >= 5)
		{
			itemImage++;
			frame = 0;
		}
		g.drawImage(now,Math.round(getScreenX()),Math.round(getScreenY()-now.getHeight(null)),null);
	}
	
}
